var app = getApp();
var mfApi = require('../../api/api.js');

Page({
    data: {
        baseUrl: app.globalData.baseUrl,
        shotImagePath: '',

        // 是否分享成功了 
        isShareSuccess: false
    },

    onLoad: function (option) {
        console.log('onLoad');
        console.log(option)
        this.setData({
            shotImagePath: option.shotImagePath
        })
    },

    onShareAppMessage(inData) {
        console.log("onShareAppMessage    =-=-=-=-==");
        console.log(inData);
        let tempChannel = inData.target.id == "share-wx" ? "Wxfriends" : 'Wxmoments';
        return {
            mpId: app.globalData.appId,
            title: 'wans穿搭title',
            type: 2,
            desc: '2022_vansdress_jd 穿搭',
            imageUrl: app.globalData.baseUrl + "/share/share_page.png",
            path: 'pages/magicBox/boxIndex/boxIndex',
            channel: tempChannel,
            success: () => {
                console.log("show  share   ok")
                this.setData({
                    isShareSuccess: true
                })
            }
        }
    },

    handleLongPress() {
        jd.saveImageToPhotosAlbum({
            filePath: this.data.shotImagePath,
            success(res) {
                jd.showToast({
                    title: '保存成功'
                })
            }
        })

        // mfApi.uploadFile(mfApi.uploadFileUrl(), this.data.shotImagePath).then(res => {
        //     console.log("upload --- res" , res)
        // })

    },

    onBackToDiyClick() {
        jd.navigateBack({
            delta: 1
        });
    }
});